From 69a9bab277d5427be612914d0cad3c5781b18573 Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Thu, 12 Apr 2007 12:12:56 +0100 Subject: [PATCH] HVM: Do not watch control/shutdown to force domain shutdowns when PV drivers are not present. The feature-foo mechanism does not actually work after save/restore since the fields do not get rewritten. And it doesn't work when we actually need the guest to be shutdown through Xen (e.g., on suspend). Since we can quite reasonably assume that the only entity to screw with control/shutdown is xend, and since the one place that does that now explicitly handles unenlightened HVM guests, we can simply strip all this stuff out. This has the nice benefit of making HVM save/restore with PV drivers much more reliable. Signed-off-by: Keir Fraser --- .../drivers/xen/core/reboot.c | 3 +- tools/python/xen/xend/XendDomainInfo.py | 1 - tools/python/xen/xend/image.py | 75 ------------------- 3 files changed, 1 insertion(+), 78 deletions(-) diff --git a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c index cb95ac9326..ee6625adc6 100644 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c @@ -118,6 +118,7 @@ static void shutdown_handler(struct xenbus_watch *watch, err = xenbus_transaction_start(&xbt); if (err) return; + str = (char *)xenbus_read(xbt, "control", "shutdown", NULL); /* Ignore read errors and empty reads. */ if (XENBUS_IS_ERR_READ(str)) { @@ -206,14 +207,12 @@ static int setup_shutdown_watcher(void) printk(KERN_ERR "Failed to set shutdown watcher\n"); return err; } - xenbus_write(XBT_NIL, "control", "feature-reboot", "1"); err = register_xenbus_watch(&sysrq_watch); if (err) { printk(KERN_ERR "Failed to set sysrq watcher\n"); return err; } - xenbus_write(XBT_NIL, "control", "feature-sysrq", "1"); return 0; } diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 9083e90e77..1ccf7d4f2b 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -1601,7 +1601,6 @@ class XendDomainInfo: self.image = image.create(self, self.info) if self.image: self.image.createDeviceModel(True) - self.image.register_shutdown_watch() self._storeDomDetails() self._registerWatches() self.refreshShutdown() diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py index ecdea40074..8f119b3ae1 100644 --- a/tools/python/xen/xend/image.py +++ b/tools/python/xen/xend/image.py @@ -284,9 +284,6 @@ class HVMImageHandler(ImageHandler): log.debug("acpi = %d", self.acpi) log.debug("apic = %d", self.apic) - self.register_shutdown_watch() - self.register_reboot_feature_watch() - return xc.hvm_build(domid = self.vm.getDomid(), image = self.kernel, store_evtchn = store_evtchn, @@ -448,13 +445,9 @@ class HVMImageHandler(ImageHandler): log.info("device model pid: %d", self.pid) def recreate(self): - self.register_shutdown_watch() - self.register_reboot_feature_watch() self.pid = self.vm.gatherDom(('image/device-model-pid', int)) def destroy(self, suspend = False): - self.unregister_shutdown_watch() - self.unregister_reboot_feature_watch(); if self.pid: try: sig = signal.SIGKILL @@ -473,74 +466,6 @@ class HVMImageHandler(ImageHandler): pass self.pid = None - def register_shutdown_watch(self): - """ add xen store watch on control/shutdown """ - self.shutdownWatch = xswatch(self.vm.dompath + "/control/shutdown", - self.hvm_shutdown) - log.debug("hvm shutdown watch registered") - - def unregister_shutdown_watch(self): - """Remove the watch on the control/shutdown, if any. Nothrow - guarantee.""" - - try: - if self.shutdownWatch: - self.shutdownWatch.unwatch() - except: - log.exception("Unwatching hvm shutdown watch failed.") - self.shutdownWatch = None - log.debug("hvm shutdown watch unregistered") - - def hvm_shutdown(self, _): - """ watch call back on node control/shutdown, - if node changed, this function will be called - """ - xd = xen.xend.XendDomain.instance() - try: - vm = xd.domain_lookup( self.vm.getDomid() ) - except XendError: - # domain isn't registered, no need to clean it up. - return False - - reason = vm.getShutdownReason() - log.debug("hvm_shutdown fired, shutdown reason=%s", reason) - if reason in REVERSE_DOMAIN_SHUTDOWN_REASONS: - vm.info['shutdown'] = 1 - vm.info['shutdown_reason'] = \ - REVERSE_DOMAIN_SHUTDOWN_REASONS[reason] - vm.refreshShutdown(vm.info) - - return True # Keep watching - - def register_reboot_feature_watch(self): - """ add xen store watch on control/feature-reboot """ - self.rebootFeatureWatch = xswatch(self.vm.dompath + "/control/feature-reboot", \ - self.hvm_reboot_feature) - log.debug("hvm reboot feature watch registered") - - def unregister_reboot_feature_watch(self): - """Remove the watch on the control/feature-reboot, if any. Nothrow - guarantee.""" - - try: - if self.rebootFeatureWatch: - self.rebootFeatureWatch.unwatch() - except: - log.exception("Unwatching hvm reboot feature watch failed.") - self.rebootFeatureWatch = None - log.debug("hvm reboot feature watch unregistered") - - def hvm_reboot_feature(self, _): - """ watch call back on node control/feature-reboot, - if node changed, this function will be called - """ - status = self.vm.readDom('control/feature-reboot') - log.debug("hvm_reboot_feature fired, module status=%s", status) - if status == '1': - self.unregister_shutdown_watch() - - return True # Keep watching - class IA64_HVM_ImageHandler(HVMImageHandler): -- 2.30.2